package de.fhtrier.gdw2.ships.utils;

import java.util.HashMap;

import org.newdawn.slick.AngelCodeFont;
import org.newdawn.slick.Font;
import org.newdawn.slick.Image;
import org.newdawn.slick.Music;
import org.newdawn.slick.SlickException;

public class AssetLoader
	{
		public static AssetLoader assetLoader;

		HashMap<String, Font> fonts = new HashMap<>();
		HashMap<String, Image> images = new HashMap<>();
		private Music music;

		public static AssetLoader getInstance()
			{
				return assetLoader;
			}

		static
			{
				try
					{
						assetLoader = new AssetLoader();
					} catch (Exception e)
					{
						e.printStackTrace();
						System.exit(-1);
					}
			}

		private AssetLoader() throws SlickException
			{
				setupImages();
				setupFonts();
				music = new Music("res/runaway.ogg");
			}

		private void setupImages() throws SlickException
			{
				images.put("mod_weap_A", new Image("res/shipcomps/weapon/weaponA.gif"));
				images.put("mod_weap_B", new Image("res/shipcomps/weapon/weaponB.gif"));
				images.put("mod_weap_D", new Image("res/shipcomps/weapon/weaponD.gif"));
				images.put("mod_weap_AB", new Image("res/shipcomps/weapon/weaponAB.gif"));
				images.put("mod_weap_AD", new Image("res/shipcomps/weapon/weaponAD.gif"));
				images.put("mod_ener_A", new Image("res/shipcomps/energy/energyA.gif"));
				images.put("mod_ener_B", new Image("res/shipcomps/energy/energyB.gif"));
				images.put("mod_ener_C", new Image("res/shipcomps/energy/energyC.gif"));
				images.put("mod_ener_D", new Image("res/shipcomps/energy/energyD.gif"));
				images.put("mod_central", new Image("res/shipcomps/central/central.gif"));
				images.put("mod_shield", new Image("res/shipcomps/shield/shieldI.gif"));
				images.put("mod_antrieb_B", new Image("res/shipcomps/antrieb/antriebB.gif"));
				images.put("mod_antrieb_C", new Image("res/shipcomps/antrieb/antriebC.gif"));
				images.put("mod_antrieb_CB", new Image("res/shipcomps/antrieb/antriebCB.gif"));
				images.put("mod_antrieb_CD", new Image("res/shipcomps/antrieb/antriebCD.gif"));
				images.put("mod_antrieb_D", new Image("res/shipcomps/antrieb/antriebD.gif"));
				
				
				images.put("rund", new Image("res/bricks/rund.png"));
				images.put("target_flag", new Image("res/bricks/flag.gif"));
				

			}

		private void setupFonts() throws SlickException
			{
				putFont("verdana_24");
				putFont("verdana_32");
				putFont("verdana_46");
				putFont("verdana_90");
				putFont("quartz_40");
				putFont("quartz_50");
			}

		private void putFont(String name) throws SlickException
			{
				fonts.put(name, new AngelCodeFont("res/fonts/" + name + ".fnt",
						"res/fonts/" + name + "_0.tga"));
			}

		public Font getFont(String name)
			{
				return fonts.get(name);
			}

		public Image getImage(String name)
			{
				return images.get(name);
			}

		/**
		 * @return the music
		 */
		public Music getMusic()
			{
				return music;
			}

	}